//July 22, 2017#include #defineLEN 15intMain () {intN; voidBinsearch (int* p,intN); intarr[len]={98, the, the, the, the, -, $, Wu, +, the, the, $, *, to, in}; printf ("Please enter the number you want to find: \ n"); scanf ("%d",N); Binsearch (Arr,n); return 0;}voidBinsearch (int* p,intN) { intLow,high,mid; Low=0; High=len-1; while(lowHigh ) {Mid= (Low+high)/2; if(p[mid]==N) {printf ("%d is the value of the%d element of the array (subscript sta
Topic:To count the number of occurrences of a number in a sorted array, such as the sort array {1,2,3,3,3,4,5}, the number 3 appears is 3.
Ideas for solving problems:1. First of all, traversing an array is sure to know the number of a number, at this time the complexity O (n
Topic:Counts the number of occurrences of a number in a sorted array.Ideas:Because it is a well-ordered array, a binary lookup algorithm can be used.Generally the most easily thought of the idea is to use a binary search to find a first, and then go to his left and right side of the traverse, but this method because in the N array may also have n K, soThe complex
Topic:In the sorted array, find out the number of occurrences of a given numberIdeas:Since there is a sort array, it is easy to think of binary lookups, with time complexity O (LOGN);First, by binary find the leftmost occurrence of the number of the subscript left (if not found, then return-1), and then through the binary search find the rightmost occurrence of the numb
quicksearch function that has the largest number of K before it is quickly found.finding the number of K-large based on the idea of fast sortingfunctionQuickSearch (a,left,right,k) {if(kreturn-1;//Focus 1, when the value of K does not meet the requirements, return-1 if(Left==right)returnA[left];//Focus 2, the end condition of the recursionLet Key=-1,len=0; if(leftRight ) {Key=partition (A,left,right); L
public class Employeedemo {//Method one: public int search (string str,string strres) {//lookup string in the same number as the specified string int n=0;//counter//for (int i = 0;i The same number in the Java lookup string as the specified string
in the arrayTwo clear:return value type: intParameter list: int[] arr,int value*/ Public Static intGetIndex (int[] arr,intvalue) { //iterate through the array, get each element in the array, and compare the known data for(intx=0; x) { if(Arr[x] = =value) { //returns the current index value if it is equal. returnx; } } //The current code has a small problem//That is, if the data I am looking for does not exist in
For example, to find the AAA string in the ABC catalogue.
Grep-rn "AAA"/wwwroot/abc/the current directory.
-R indicates recursive lookup-n for displaying line numbers
VI How the open document displays line numbers
Set:number
Do not show line numbers
Set:nonumber
Jumps to a specified number of lines, such as 100 lines
Enter 100G carriage return
Example
Find "hello,world!" String, you can do this:
Find Clevercode in the current directory and subdirectories, all PHP occurrences are greater than 0 times.# find-type f-name ' *.php ' | Xargs grep clevercode./*.php-rc | Awk-f ': ' $ > 0 {print $1,$2} ' | Grep-v '/.svn/' | Sort-n-K 2-r1) find-type f-name ' *.php '. Finds all PHP files in the current directory and subdirectories.2) xargs grep clevercode./*.php-rc. Finds the Clevercode keyword in each file and displays the number of occurrences.3) awk-
Find Clevercode in the current directory and subdirectories, all PHP occurrences are greater than 0 times.# find-type f-name ' *.php ' | Xargs grep clevercode./*.php-rc | Awk-f ': ' $ > 0 {print $1,$2} ' | Grep-v '/.svn/' | Sort-n-K 2-r1) find-type f-name ' *.php '. Finds all PHP files in the current directory and subdirectories.2) xargs grep clevercode./*.php-rc. Finds the Clevercode keyword in each file and displays the number of occurrences.3) awk-
For monitoring needs, you must call MongoDB's PID,Method 1:Add in the interactive file, pidfilepath=/var/run/mongodb.pid, restart MongoDB,Note that 2.5.3 below the version, the PID file is not found, this is a bug, in 2.5.3 or more versions before repair;Method 2: write the script to get it: the main content of the scriptPid= ' PS aux|grep mongodb |awk ' {print $} ' |sed-n ' 1p 'Method 3: inadvertently go to the data directory of MongoDB, found a mongod.lock, the inside record is PIDThen make a
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.